package org.gry.dy20180723;

public class TestRecursion {

	public static void main(String[] args) {
		long d1 = System.currentTimeMillis();  
        System.out.printf("%d阶乘的结果:%s%n", 10, cheng(10));
    	long d2 = System.currentTimeMillis();  
    	System.out.printf("递归费时：%s%n", d2-d1);  //耗时：32ms
	}

	static int cheng(int a) {
		if (a > 0) {
			int g = a * cheng((a - 1));
			System.out.println(g);
			return g;
		}else {
			return 1;
		}
	}
	/*
	 * static int a;
	 * 
	 * static void a1() { a++; if(a<10) { System.out.println(a+"a1"); a1(); }else {
	 * return; } }
	 * 
	 * static void a2() { System.out.println("a2"); }
	 */
}
